package com.briup.controller;

import com.briup.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @program: book-case
 * @description: swagger测试
 * @author: rendc
 * @create: 2024-12-12 09:26
 **/
@Api(tags = "Swagger测试") // 用来指定当前API模块的名称
@RestController
@RequestMapping("/swagger")
public class SwaggerController {
    @ApiOperation(notes = "swagger测试",value="test") // api简介
    @ApiImplicitParams(
        {
        @ApiImplicitParam(name = "name",value ="用户名",required = true,dataType="String")
        }
    )
    @GetMapping("/hello")
    public String hello(String name){
        System.out.println("in hello...");
        return "hello，swagger"+name;
    }

    @ApiOperation(notes = "id必须存在",value="根据id删除用户") // api简介
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "id",value ="用户id",required = true,dataType="long",paramType = "path")
            }
    )
    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Long id){
        System.out.println("in deleteById ...id:"+id);
        return Result.success("删除成功");
    }

    @ApiOperation(value="根据用户名和密码登录系统",notes = "输入用户名密码登录") // api简介
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "name",value ="用户名",required = true,dataType="String",paramType = "form"),
                    @ApiImplicitParam(name = "password",value ="密码",required = true,dataType="String",paramType = "form"),
            }
    )
    @PostMapping(value = "/login",consumes = "application/x-www-form-urlencoded")
    public Result login(@RequestParam("name") String name,
                        @RequestParam("password") String password){
        System.out.println("in login ...name:"+name);
        System.out.println("in login ...password:"+password);
        return Result.success("登录成功");
    }



}
